//
// Created by hsj on 2024-5-15.
//

#include<iostream>
#include<cstring>
#include<string>
int main(void){
    using namespace std;
    char charr[10] ;
    string str;

    cout << "Length of string in charr before input: "
         << strlen(charr) << endl ;//纠正书上的错误，这里是0，见图片: strchar.jpg
    cout << "Length of string in str before input: "
         << str.size() << endl ;

    cout << "Enter a line of text: \n";
    cin.getline(charr, 10);
// indicate maximum length
    cout << "You entered:"<< charr << endl ;
    cout << "Enter another line of text: \n" ;
    getline(cin, str) ;

// cin now an argument; no length specifier
    cout << "You entered: "<< str << endl ;
    cout << "Length of string in charr after input: "
         << strlen(charr) << endl ;
    cout << "Length of string in str after input: "
         << str.size() << endl ;

    return 0;
}